home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / EmacsTeX / Emacs-3.0.1 / Source / EmacsApp.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  3.1 KB  |  134 lines

  1. /* The Application implementation for Emacs.
  2.  
  3.    For legal stuff see the file COPYRIGHT.  */
  4.  
  5. #import "EmacsApp.h"
  6. #import "EditListener.h"
  7.  
  8. @implementation EmacsApp
  9.  
  10.   /* Some things have to be taken care of before we start up.           */
  11. -appWillInit: sender
  12. {
  13.   /* Stuff to handle opening up a afile and posistioning the cursor at a
  14.      specific line number.                           */
  15.   editListener = [[EditListener alloc] init];
  16.   [NXApp setAppListener:editListener];
  17.   return self;
  18. }
  19.  
  20.   /* We're ready to start.  Size the window apropriately and fire up the
  21.      emacs process, possibly editing a file.                   */
  22. -appDidInit: sender
  23. {
  24.   id window;
  25.  
  26.   DPSSetDeadKeysEnabled (DPSGetCurrentContext (), NO);
  27.  
  28.   window = [currentView window];
  29.   [window setBackgroundGray: NX_WHITE];
  30.   [window removeFromEventMask: NX_KEYUPMASK | NX_FLAGSCHANGEDMASK];
  31.   [window makeFirstResponder: currentView];
  32.   [window setFrameUsingName: "main"];
  33.   [window setFrameAutosaveName: "main"];
  34.  
  35.   [currentView startEmacs];
  36.  
  37.   if (!strcmp (NXGetDefaultValue ([NXApp appName], "NXAutoLaunch"), "YES")
  38.       && !strcmp (NXGetDefaultValue ([NXApp appName],
  39.                      "HideOnAutoLaunch"), "YES"))
  40.     [self hide: self];
  41.   else
  42.     [self appDidUnhide: self];
  43.   [self setDelegate: self];
  44.   return self;
  45. } /* -appDidInit: */
  46.  
  47. -appDidUnhide: sender
  48. {
  49. #if 0
  50.   int eventChannel;
  51.  
  52.   evenChannel = [currentView eventChannel];
  53.   if (eventChannel)
  54.     fprintf (eventChannel, "(redraw-display)\n");
  55. #endif
  56.   [[currentView window] makeKeyAndOrderFront: self];
  57.   return self;
  58. } /* -appDidUnhide */
  59.  
  60. /* Intercept the Quit command and replace it with C-x C-c.  */
  61. -terminate: sender
  62. {
  63.   if (sender && [currentView quitEmacs])
  64.     return self;
  65.   return [super terminate: sender];
  66. } /* -terminate: */
  67.  
  68. -(BOOL) appAcceptsAnotherFile: sender
  69. {
  70.   return YES;
  71. } /* appAcceptsAnotherFile: */
  72.  
  73. /* Stash the name of a file in an instance variable so we can give it to the
  74.    child emacs when we fire it up.  */
  75. -(BOOL) app: sender openFile: (const char *) path type: (const char *) type
  76. {
  77.   return [currentView newFile: path];
  78. } /* -app:openFile:type: */
  79.  
  80. -currentView
  81. {
  82.   return currentView;
  83. } /* -currentView */
  84.  
  85. -fontManager
  86. {
  87.   if (!fontManager)
  88.     {
  89.       fontManager = [FontManager new];
  90.       [fontManager setDelegate: self];
  91.     }
  92.   return fontManager;
  93. } /* -fontManager */
  94.  
  95. -showFontPanel: sender
  96. {
  97.   [[NXApp fontManager] orderFrontFontPanel: self];
  98.   [fontManager setSelFont: [currentView font] isMultiple: NO];
  99.   return self;
  100. } /* -showFontPanel: */
  101.  
  102. -(BOOL) fontManager: sender willIncludeFont: (const char *) fontName
  103. {
  104.   NXFontMetrics *metrics;
  105.   id font;
  106.  
  107.   font = [Font newFont: fontName size: (float) 10];
  108.   if (font != nil)
  109.     {
  110.       metrics = [font readMetrics: NX_FONTHEADER];
  111.       if (metrics != NULL)
  112.     return metrics->isFixedPitch;
  113.     }
  114.   return NO;
  115. } /* fontManager:willIncludeFont: */
  116.  
  117. -(int)openFile : (char *) fileName
  118.     onHost : (char *) hName
  119.     atTrueLine : (int) line
  120. {
  121.   return [currentView openFile:fileName onHost:hName atTrueLine:line];
  122. }
  123.  
  124. -(int)openFile : (char *) fileName
  125.     onHost : (char *) hName
  126.     fromTrueLine : (int) line1
  127.     to : (int) line2
  128. {
  129.   return [currentView openFile:fileName onHost:hName fromTrueLine:line1
  130.               to:line2];
  131. }
  132.  
  133. @end
  134.